/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$(document).ready(
    function() 
    {
        $('.searchbar').children('form').children('img').click
        (
            function ()
            {
                $(this).parent().submit();
            }
        );
        $('#navigation a').mouseover
        (
            function ()
            {
                if($(this).attr("id")=="hover"){
                    var position = $('#navigation a').position();
                    var height =  $('#navigation a').height();
                    $('#sections').css("display", "block");
                    $('#sections').offset({top: position.top + height -5, left: position.left});
                }
            }
        );
        $('.hoverMenu').mouseleave
        (
            function ()
            {
                $(this).css("display", "none");
            }
        );
        $('.hoverMenu li').mouseover
        (
            function ()
            {
                $(this).css("background-color", "#444444");
                $(this).css("color", "#4f0000");
                $(this).css('cursor','pointer');
                $(this).children('.hoverMenu').css("display", "block");
                $(this).children('.hoverMenu').children('ol').css("position", "absolute");
                $(this).children('.hoverMenu').children('ol').css("z-index", "3");
                $(this).children('.hoverMenu').children('ol').css("left", "217px");
                $(this).children('.hoverMenu').children('ol').css("top", "-24px");
            }
        );
        $('.hoverMenu li').mouseleave
        (
            function ()
            {
                $(this).css("background-color", "#999999");
                $(this).css("color", "#ffffff");
                $(this).children('.hoverMenu').css("display", "none");
            }
        );
        $('li.liSousSection').click
        (
            function ()
            {
                $(this).children('form').submit();
            }
        );
        $('li.liDiscussion').click(
            function(event)
            {
                event.stopPropagation();
                $(this).children('form').submit();
            }
        );
        $('.imgBackground').click
        (
            function ()
            {
                if($(this).attr('id')=="bg0")
                {
                    $('html').css("background-image","");
                }
                else
                {
                    var src = $(this).attr("src").replace("select-","");
                    $('html').css("background-image","url('"+src+"')");
                }
                // On change la variable de session de fond d'écran
                changerFondEcran($(this).attr('id'));
            }
        );
            
        /*
         * Fonction pour empêcher de soumettre un formulaire en appuyant 
         * sur Entrer dans un champ de texte contenant la class "noSubmitEnter"
         */
        $('.noSubmitEnter').keypress(function(e){
            if(e.keyCode == 10 || e.keyCode == 13)
            {
                e.preventDefault();
            }
        });

        // On choisi le fond d'écran    
        var choix = $('#idBackground').attr('value');
        $('#' + choix).click();
    }
);

